﻿using Library.Collections.Specialized;
using Library.Collections.Generic;
using System;
using System.Linq;
using System.Linq.Expressions;
using TRULE = System.Linq.Expressions.Expression<System.Func<System.Linq.IQueryable<System.Linq.Expressions.Expression>, System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression>>>>;
using TEXPRESSION = System.Linq.Expressions.Expression;

namespace Library.Logic.Inference
{
    public static partial class Extensions
    {
        public static bool Entails<TExpression>(this IReasonerReadOnly<TExpression> reasoner, TExpression expression)
        {
            return reasoner.Contains(expression);
        }

        public static bool Entails<TExpression>(this IReasonerReadOnly<TExpression> reasoner, IQueryable<TExpression> expressions, TExpression expression)
        {
            return reasoner.Reason(expressions).Contains(expression);
        }
    }

    public interface IReasonerReadOnly<TStatement> : IQueryable<TStatement>, IContainer<TStatement>
    {
        IQueryable<TStatement> Reason(IQueryable<TStatement> input);
    }

    public interface IReasonerReadOnly<TStatement, TRule> : IReasonerReadOnly<TStatement>, IContainerReason<TStatement>
    {
        IQueryable<TRule> Rules { get; }
    }

    //public interface IReasonerReadOnly<T> : IReasonerReadOnly<Expression<Func<IQueryable<T>, IQueryable<T>>>, T> { }
}